﻿using System;
using System.Windows.Controls;
using System.Windows.Threading;

namespace Oliver.Apps.Windows7Countdown.Controls
{
    public partial class CountdownTimer : UserControl
    {
        public CountdownTimer()
        {
            InitializeComponent();

            timer = new DispatcherTimer();
            timer.Tick += timer_Tick;
            timer.Interval = new TimeSpan(0, 0, 1);
            timer.Start();
        }
        
        DispatcherTimer timer;

        void timer_Tick(object sender, EventArgs e)
        {
            Update();
        }

        private void Update()
        {
            //this.DataContext = Settings.TimeLeftText;
        }

        ~CountdownTimer()
        {
            Dispatcher.BeginInvoke(() =>
                {
                    timer.Tick -= timer_Tick;
                });
        }
    }
}
